﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;
using Microsoft.Practices.Prism.Commands;
using DIST.LR.ZHJG.Events;
using HSE.Events;

namespace HSE.Common
{
    public class ButtonColumn : GridViewColumn
    {

        ResourceDictionary resources;
        public ButtonInfo bInfo{
            get;
            set;
        }
        public ButtonColumn()
        {
            resources = new ResourceDictionary();
            resources.Source = new Uri("/HSE;component/Themes/Button.xaml", UriKind.Relative);
            //bInfo = new ButtonInfo() { Alias="编辑", Icon = "Images/Camera.png", Style = "ImageTextButtonStyle"};
            //bInfo.ClickDelegate = new DelegateCommand<object>(myCommand_Execute1);
        }
            

        public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            RadButton button = cell.Content as RadButton;
            if (button == null)
            {
                button = new RadButton();
                //button.Content = "Delete";
                button.DataContext = bInfo;
                button.Style = resources[bInfo.Style] as Style;
                //button.Command = new DelegateCommand<object>(myCommand_Execute);
                button.Command = bInfo.ClickDelegate;
            }

            button.CommandParameter = dataItem;

            return button;
        }

    }

    public class ButtonInfo
    {
        public string Alias { get; set; }
        public string Icon { get; set; }
        public string Style { get; set; }

        public ICommand ClickDelegate { get; set; }
    }
}
